ImageGear Java PDF
Samples

ImageGear Java PDF provides the following samples to help get you started. They are located in the $HOME/Accusoft/ImageGearJavaPDF1-64/samples folder.

Please refer to the “How to Build and Run Samples” section below for help getting started with building the samples.

Sample Name This sample illustrates how to...

Arguments Available

(where [] indicates an optional argument)

AddImageSample Add an image to a page of a PDF document. <input_file_path> [<position> [<output_file_path>]]
IGJavaInteroperabilitySample Integrate ImageGearJava and ImageGearPDFJava libraries. To run this sample you are required to install ImageGear for Java. <input_file_path> [<output_file_path>]
ImageToPDFSample Create a PDF document from an image. <input_file_path> [<output_file_path>]
InsertPagesSample Insert pages from one PDF document into another PDF document. <destination_file_path> <insert_at_page_number> <source_file_path> [<start_page_number> [<page_count>]]
MergePDFSample Merge two PDF documents. <input_file_path1> <input_file_path2> [<output_file_path>]
OpenSaveSample Open and save a PDF document. <input_file_path> [<output_file_path> [<save_with_LINEARIZED_flag>]]
RenderSample Open and render a PDF document to an image. <input_file_path> [<page_number> [<output_file_path> [<resolution> [<smoothing_flags>]]]]
SplitPDFSample Split a PDF document. <input_file_path> [<number_of_pages>]

Sample Usage

 
Copy Code
java -jar RenderSample-1.1.jar "single-page.pdf" "single-page-output.pdf"

The above command runs the RenderSample and specifies "single-page.pdf" as the <input_file_path>, "single-page-output.pdf" as the <output_file_path>. Note the <page_number>, <resolution>, and <smoothing_flags> aren't specified, so the default values are used.

For each sample you can also specify the -h command-line option, which will display an explanation of the different options available and how to use the sample.

How to Build and Run Samples

This section describes how to build and run the code samples.

Using Maven:

  1. Go to the sample folder. For example, for the OpenSaveSample use the following command:
     
    Copy Code
    cd  $HOME/Accusoft/ImageGearJavaPDF1-64/samples/OpenSaveSample
    
  2. In the sample folder run the following command:
     
    Copy Code
    mvn package
    

    After the command has successfully completed, the "target" folder will be created in the sample folder.

  3. Run the sample with the following command:
     
    Copy Code
    java -jar ./target/OpenSaveSample-1.1.jar "../SampleData/Pdf/single-page.pdf" "../SampleData/Pdf/single-page-output.pdf" false
    

Using Java command-line tools:

  1. Go to the sample folder. For example, for the OpenSaveSample use the following command:
     
    Copy Code
    cd  $HOME/Accusoft/ImageGearJavaPDF1-64/samples/OpenSaveSample
    
  2. Build the sample using javac. For example, for the OpenSaveSample use the following command:
     
    Copy Code
    javac -classpath "../../java/IgPdf.jar" ./src/com/accusoft/samples/OpenSaveSample/OpenSaveSample.java
    
  3. Run the sample with Java. For example, for the OpenSaveSample use the following command:
     
    Copy Code
    java -classpath "../../java/IgPdf.jar:./src/" com.accusoft.samples.OpenSaveSample.OpenSaveSample  "../SampleData/Pdf/single-page.pdf" "../SampleData/Pdf/single-page-output.pdf" true
    

To run the IGJavaInteroperabilitySample, use the following command:

 
Copy Code
java -classpath "<ImageGearJava>/lib/imagegear2.art.jar:<ImageGearJava>/lib/imagegear2.core.jar:
<ImageGearJava>/lib/imagegear2.evaluation.jar:
<ImageGearJava>/lib/imagegear2.formats.common.jar:
<ImageGearJava>/lib/imagegear2.formats.advanced.jar:./target/IGJavaInteroperabilitySample-1.1.jar"
com.accusoft.samples.IGJavaInteroperabilitySample.IGJavaInteroperabilitySample 
"../SampleData/Images/tiff-image.tif" "../SampleData/Pdf/tiff-image-added.pdf"

where <ImageGearJava> is the folder where ImageGear for Java was installed.

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback